/**
 * @Description:     增加移动端测试控制台，
                     在页面中找到任意输入框，
                     输入'@111'可以调出移动端控制台，
                     输入'@222'可以删除移动端控制台
 * @author Sun Yan
 * @date $
 */
window.vConsole = "";
if (localStorage.getItem("vconsole") === "1") {
    let scri = document.createElement('script');
    scri.src = "https://unpkg.com/vconsole/dist/vconsole.min.js";
    scri.onload = function() {
        window.vConsole = new VConsole();
    }
    document.body.appendChild(scri);
};


document.addEventListener("input", function(e) {
    let val = e.target.value;
    if (val === "@111") {
        localStorage.setItem("vconsole", "1");
        if (!window.vConsole) {
            let scri = document.createElement('script');
            scri.src = "https://unpkg.com/vconsole/dist/vconsole.min.js";
            scri.onload = function() {
                window.vConsole = new VConsole();
                alert('script onload')
            }
            alert('create script')
            window.document.body.appendChild(scri)
            window.setTimeout(_=> {
                if(!window.vConsole && !!VConsole) {
                    window.vConsole = new VConsole();
                }
            }, 2000)
        } else {
            window.vConsole = new VConsole();
            alert(JSON.stringify(window.vConsole))
        }
    } else if (val === "@222") {
        localStorage.setItem("vconsole", "2");
        if (window.vConsole) {
            window.vConsole.destroy();
            window.vConsole = "";
        }
    }
}, false)


window.testOpen = function  (adminIndex = 0) {
    let arr = [
        'http://192.168.3.219:1234',
        'http://192.168.3.204:1234',
        'http://www.baidu.com'
    ]
    window.sessionStorage.setItem('testBaseURL', arr[parseFloat(adminIndex)])
    window.location.href = arr[parseFloat(adminIndex)]
}

if(window.location.hostname === 'appnfs.apppsy.com' && window.sessionStorage.getItem('testBaseURL')) {
    window.location.href = window.sessionStorage.getItem('testBaseURL')
}